/*
 * Copyright (C) 2015 kmy-framework-base Project
 *               Author: Administrator
 *               Date: 2015年11月4日
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.zmq.ha.client.declaration;

import java.io.Serializable;
import java.util.Map;

/**
 * 
 * Name: Binding.java
 * ProjectName: [kmy-framework-base]
 * Package: [com.kmy.framework.rabbitmq.recover.declaration.Binding.java]
 * Description: 绑定描述类  
 * 
 * @since JDK1.7
 * @see
 *
 * Author: @author: Chris
 * Date: 2015年11月4日 下午4:03:20
 *
 * Update-User: @author
 * Update-Time:
 * Update-Remark:
 * 
 * Check-User:
 * Check-Time:
 * Check-Remark:
 * 
 * Company: kmy
 * Copyright: kmy
 */

public class Binding implements Serializable {
	
	/** 
	 * @Fields serialVersionUID : TODO
	 */ 
	  private static final long serialVersionUID = 3815840905253145624L;
	  public String destination;
	  public final String source;
	  public final String routingKey;
	  public final Map<String, Object> arguments;

	  @SuppressWarnings("unchecked")
	  public Binding(Object[] args) {
	    destination = (String) args[0];
	    source = (String) args[1];
	    routingKey = (String) args[2];
	    arguments = args.length > 3 ? (Map<String, Object>) args[3] : null;
	  }

	  @Override
	  public int hashCode() {
	    final int prime = 31;
	    int result = 1;
	    result = prime * result + ((arguments == null) ? 0 : arguments.hashCode());
	    result = prime * result + ((destination == null) ? 0 : destination.hashCode());
	    result = prime * result + ((routingKey == null) ? 0 : routingKey.hashCode());
	    result = prime * result + ((source == null) ? 0 : source.hashCode());
	    return result;
	  }

	  @Override
	  public boolean equals(Object obj) {
	    if (this == obj)
	      return true;
	    if (obj == null)
	      return false;
	    if (getClass() != obj.getClass())
	      return false;
	    Binding other = (Binding) obj;
	    if (arguments == null) {
	      if (other.arguments != null)
	        return false;
	    } else if (!arguments.equals(other.arguments))
	      return false;
	    if (destination == null) {
	      if (other.destination != null)
	        return false;
	    } else if (!destination.equals(other.destination))
	      return false;
	    if (routingKey == null) {
	      if (other.routingKey != null)
	        return false;
	    } else if (!routingKey.equals(other.routingKey))
	      return false;
	    if (source == null) {
	      if (other.source != null)
	        return false;
	    } else if (!source.equals(other.source))
	      return false;
	    return true;
	  }
	}
